package pet;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Random random = new Random();
        final int PET_COUNT = 1000;
        PetShop petShop = new PetShop(1000);

        // 随机生成1000个宠物信息
        for (int i = 0; i < PET_COUNT; i++) {
            String name = "Pet" + i; // 宠物名字
            int age = random.nextInt(15); // 年龄0到15
            int weight = random.nextInt(101); // 体重0到100
            int activity = random.nextInt(101); // 活跃度0到100
            int sensitivity = random.nextInt(101); // 灵敏度0到100
            Pet pet = new Pet(name, age, weight, activity, sensitivity);
            petShop.addPet(pet, i);
        }

        HashMap<Double,Integer> hm=new HashMap<>();

        Double[] arr=new Double[PET_COUNT];
        for(int i=0;i<PET_COUNT;i++){
            arr[i]=PetShop.pets[i].score;
            hm.put(arr[i], i);
        }

        // 根据平均值降序排列宠物
        Arrays.sort(arr, new Comparator<>(){
            public int compare(Double a, Double b){
                return (int)(b-a);
            }
        });

        // 打印所有宠物信息
        Pet temp;
        Iterator<Map.Entry<Double, Integer> > it =hm.entrySet().iterator();
        for (int i=0;i<PET_COUNT;i++) {
            temp=PetShop.pets[hm.get(arr[i])];
            System.out.print("Name: " + temp.name+", ");
            System.out.print("Age: " + temp.age + ", ");
            System.out.print("weight: " + temp.weight + ", ");
            System.out.print("Activity: " + temp.activity + ", ");
            System.out.print("Sensitivity: " + temp.sensitivity + ", ");
            System.out.println("Average: " + temp.score);
        }


    }


}


